package com.apci.ipreda.client.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractFormController;

import com.apci.ipreda.client.web.form.DeclaracionForm;
import com.apci.ipreda.domain.Declaracion;
import com.apci.ipreda.service.DeclaracionService;

public class ConstanciaController extends AbstractFormController {

	DeclaracionService declaracionService; 
	
	protected ModelAndView processFormSubmission(
			HttpServletRequest paramHttpServletRequest,
			HttpServletResponse paramHttpServletResponse, Object paramObject,
			BindException paramBindException) throws Exception {
		// TODO Auto-generated method stub
		
		DeclaracionForm declaracionForm = (DeclaracionForm) paramObject;
		Declaracion declaracion = declaracionService.getDeclaracionById(declaracionForm.getDeclaracion().getId());
		
		declaracionForm .setDeclaracion(declaracion);
		return showForm(paramHttpServletRequest, paramBindException, "secure/formatoConstancia");
	}

	
	protected ModelAndView showForm(HttpServletRequest paramHttpServletRequest,
			HttpServletResponse paramHttpServletResponse,
			BindException paramBindException) throws Exception {
		// TODO Auto-generated method stub
		
		
		
		return showForm(paramHttpServletRequest, paramBindException, "secure/formatoConstancia");	
	}

	public void setDeclaracionService(DeclaracionService declaracionService) {
		this.declaracionService = declaracionService;
	}

}
